/*
package com.budwk.app.ocr_general;

import cn.hutool.core.io.FileUtil;
import com.baidu.aip.ocr.AipOcr;
import com.baidu.aip.util.Util;
import org.json.JSONObject;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.file.Path;
import java.util.HashMap;

*/
/**
 * @title: Sample1
 * @Author Tan
 * @Date: 2023/6/14 11:25
 * @Version 1.0
 *//*

public class Sample1 {
    public static final String APP_ID = "34810609";
    public static final String API_KEY = "E8ttVOitevZaveFWcHqxgHI2";
    public static final String SECRET_KEY = "oNO3TqVqq7sG7UbUvggqTBi8LIozM6qQ";

    private static AipOcr aipOcr;

    public static void main(String[] args) throws IOException {
        //sample(aipOcr);
        String image = "D:\\CESHI\\IMG\\89bc-e86791e8e463c027bc463eccb21c2952.jpg";
        basicAccurateGeneral(image);
    }


        public static void sample(AipOcr client) throws IOException {
        // 传入可选参数调用接口
        HashMap<String, String> options = new HashMap<String, String>();
        options.put("detect_direction", "true");
        options.put("probability", "true");


        // 参数为本地图片路径
        String image = "D:\\CESHI\\IMG\\89bc-e86791e8e463c027bc463eccb21c2952.jpg";
        JSONObject res = client.basicAccurateGeneral(image, options);
        System.out.println(res.toString(2));

        // 参数为本地图片二进制数组
        byte[] file = Util.readFileByBytes(image);
        res = client.basicAccurateGeneral(file, options);
        System.out.println(res.toString(2));

    }




    public static  JSONObject basicAccurateGeneral (String file) {

        AipOcr aipOcr = new AipOcr(APP_ID, API_KEY, SECRET_KEY);
        HashMap<String, String> options = new HashMap<>(4);
        options.put("language_type", "CHN_ENG");
        options.put("detect_direction", "true"); // 检测图片朝上
        options.put("detect_language", "true");  // 检测语言,默认是不检查
        options.put("probability", "true");   //是否返回识别结果中每一行的置信度
//方式一
        JSONObject jsonObject = aipOcr.basicAccurateGeneral(file, options);//或者是传url
//方式二
        byte[] bytes = new byte[0];
        File file1=new File(file);

        bytes = FileUtil.readBytes(file1);

        return aipOcr.basicAccurateGeneral(bytes, options);
    }












    }
*/
